package adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zzhoujay.richtext.ImageHolder;
import com.zzhoujay.richtext.RichText;

import java.util.List;

import bean.AnswerBean;
import student.andlei.com.student.R;

/**
 * author : ChenHuiMing
 * date : 2018/9/15
 * email : 907399255@qq.com
 * description : 答问模块左边适配器
 */
public class IntersionAnswerAdapter extends BaseQuickAdapter<AnswerBean.mList, BaseViewHolder> {
    public IntersionAnswerAdapter(int layoutResId, @Nullable List<AnswerBean.mList> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(final BaseViewHolder helper, AnswerBean.mList item) {
        final TextView textView = helper.getView(R.id.tv_question);
        RichText.initCacheDir(mContext);
        RichText.from(item.qa_content).bind(this)
                .showBorder(false)
                .size(ImageHolder.MATCH_PARENT, ImageHolder.WRAP_CONTENT)
                .into(textView);
        textView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                getOnItemClickListener().onItemClick(IntersionAnswerAdapter.this, textView, helper.getAdapterPosition() - 1);
            }
        });
        helper.setText(R.id.tv_subject, item.subject_name).setText(R.id.tv_time, item.create_time);
    }
}
